//
//  QDMetroLine.swift
//  QDMetroClient
//
//  Created by YueWen on 2019/3/5.
//  Copyright © 2019 YueWen. All rights reserved.
//

import Foundation
import HandyJSON


/// 所属线路的信息
struct QDNearMetroStation: HandyJSON {
    /// 线路路
    var line = 0
    /// 线路的id
    var lineId = 0
    /// 线路名称
    var lineName = ""
    /// 开始站点
    var startStation = ""
    /// 结束站点名称
    var endStation = ""
    /// 当前站点
    var thisStation = ""
    /// 过程时间
    var startFirst = ""
    /// 过程结束时间
    var startLast = ""
    /// 返程时间
    var endFirst = ""
    /// 返程结束时间
    var endLast = ""
}


/// 青岛地铁附近站点
struct QDNearMetroStationContainer:  HandyJSON {

    /// 站点名称
    var stationName = ""
    /// 站点id
    var stationId = ""
    /// 距离
    var distance = ""
    /// 是否换换乘 N 是false Y 是 true
    var isTransfer = ""
    /// 是否不可用
    var disable = false
    /// 是否是换乘
    var isTransferStation: Bool {
        get {
            return isTransfer == "Y"
        }
    }
    /// 线路数字，ex: 11
    var lineNum = ""
    /// 经过的线路名称, ex: 13号线,2号线
    var lineName = ""
    /// 经过的线路截取
    var lines: [String] {
        get {
            return (lineName as NSString).components(separatedBy: ",")
        }
    }
    /// 所属线路的数组
    var lineData = [QDNearMetroStation]()
    
}


/// 青岛地铁线路
struct QDMetroLine: HandyJSON {
    
    /// 线路id
    var lineId = "0"
    /// 站点名称,ex: 13号线
    var lineName = ""
    /// 存储的地铁站点
    var stationData: [QDMetroStation] = []
}



extension String {
 
    /// 选中的颜色
    var metroSelectColor: UIColor {
        switch self {
        case "1": return #colorLiteral(red: 0.3529411765, green: 0.6901960784, blue: 0.9490196078, alpha: 1) // 3号线
        case "2": return #colorLiteral(red: 0.9294117647, green: 0.4549019608, blue: 0.2705882353, alpha: 1) // 2号线
        case "3": return #colorLiteral(red: 0.3294117647, green: 0.4196078431, blue: 0.8196078431, alpha: 1) // 11号线
        case "4": return #colorLiteral(red: 0.3215686275, green: 0.768627451, blue: 0.6941176471, alpha: 1) // 13号线
        default: return QDColors.theme
        }
    }
}


extension QDMetroLine {
    
    /// 选中的颜色
    var selectColor: UIColor {
        get {
           return lineId.metroSelectColor
        }
    }
    
    /// 搜索选中的横条
    var rectImage: UIImage? {
        switch self.lineId {
        case "1": return "rect_3".namedImage// 3号线
        case "2": return "rect_2".namedImage // 2号线
        case "3": return "rect_11".namedImage // 11号线
        case "4": return "rect_13".namedImage // 13号线
        default: return QDColors.theme.ritl_image()
        }
    }
}


/// 青岛地铁站点信息
struct QDMetroStation: HandyJSON {

    /// 站点id
    var id = "0"
    /// 站点名称
    var name = ""
    /// 站点的拼音
    var pinyin = ""
    /// 是否不能用
    var disable = false
    /// 是否是热门站点
    var hotStation = false
    /// 是否为换乘车站
    var exchangeStation = false
    /// 线路名称
    var lineName = ""
    /// 是否是起始点
    var originStop = false
}


extension QDMetroStation : Hashable {
    
}





/// 简化的青岛地铁信息
struct QDMetroSimpleStation {
    /// 站点id
    var id = ""
    /// 站点名称
    var name = ""
    
    /// 设置站点id
    mutating func setId(id: String){
        self.id = id
    }
    
    /// 设置站点名称
    mutating func setName(name: String){
        self.name = name
    }
    
    /// 设置站点id和站点名称
    mutating func setContent(id: String, name: String){
        self.id = id
        self.name = name
    }
}
